package com.cjt2325.cameraview;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Toast;

import com.alibaba.android.arouter.launcher.ARouter;
import com.arouter.ARouterActivity3;
import com.arouter.bean.UserBean;
import com.camera.CameraActivity;
import com.kotlin.KotlinTestActivity;
import com.mvvm.MvvmTestActivity;
import com.retrofit.rxjava.RetrofitActivity;
import com.rxjava.RXJavaActivity;

public class MenuActivity extends AppCompatActivity {
    public static final int REQUEST_CODE = 0x11;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_menu);

        //重点加上这个
        //ARouter.getInstance().inject(this);
    }

    public void onMenuClick(View view){
        switch (view.getId()){
            case R.id.button1:
                startActivity(new Intent(MenuActivity.this, RetrofitActivity.class));
                break;
            case R.id.button2:
                startActivity(new Intent(MenuActivity.this, CameraActivity.class));
                break;

            case R.id.button_arouter1:
                // 1. Simple jump within application (Jump via URL in 'Advanced usage')
                ARouter.getInstance().build("/test/activity1").navigation();
                break;
            case R.id.button_arouter2:
                // 2. Jump with parameters
                UserBean userBean = new UserBean("Jack", 25);
                ARouter.getInstance().build("/test/activity2")
                        .withLong("key1", 666L)
                        .withBoolean("key2", true)
                        .withString("key3", "888")
                        .withObject("key4", userBean)
                        .navigation();
                break;

            case R.id.button_arouter3:
                ARouter.getInstance().build("/test/activity3").navigation(MenuActivity.this, REQUEST_CODE);
                break;

            case R.id.button_rxjava:
                startActivity(new Intent(MenuActivity.this, RXJavaActivity.class));
                break;
            case R.id.button_videoView:
                //http://47.106.120.137:8280/www/mp4/9CEE1F543AC177E7FD3CFD80A40D09BC.mp4
                startActivity(new Intent(MenuActivity.this, RXJavaActivity.class));
                break;
            case R.id.button_mvvm:
                startActivity(new Intent(MenuActivity.this, MvvmTestActivity.class));
            case R.id.button_kotlin:
                
                break;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(resultCode == RESULT_OK){
            if(requestCode == REQUEST_CODE){
                int arouterData = data.getIntExtra(ARouterActivity3.DATA, 0);
                Toast.makeText(MenuActivity.this, "onActivityResult====="+arouterData, Toast.LENGTH_LONG).show();
            }
        }
    }
}
